import unittest, time
from  selenium import webdriver
from ddt import ddt, data, unpack, file_data
import yaml

# def readFile():
#     # 定义一个list集合
#     params = []
#     # 通过open打开参数文档，以读取的形式，编码格式为gbk，防止中文解析
#     file = open('params.txt','r',encoding='utf-8')
#     for line in file.readlines():
#         # list中添加元素
#         params.append(line.strip('\n').split(','))
#     print(*params)
#     return params

@ddt
class forTestTest(unittest.TestCase):
    def setUp(self) -> None:
        # self.driver = webdriver.Chrome()
        # self.driver.get('http://www.baidu.com')
        pass

    def tearDown(self) -> None:
        # time.sleep(5)
        # self.driver.quit()
        pass

    # @data(*readFile())
    # @unpack
    # def test_1(self, url, txt):
    #     self.driver.get(url)
    #     self.driver.find_element_by_id('kw').send_keys(txt)
    #     self.driver.find_element_by_id('su').click()

    # @data('二哈','三十而立','异常帅气的虚竹','叶')
    # def test_2(self, txt):
    #     print(txt)

    # @data(('二哈','三十而立'),('异常帅气的虚竹','叶'))
    # @unpack
    # def test_2(self, txt, xuzhu):
    #     print(txt)
    #     print(xuzhu)
    #     print('********')

    # @data(*readFile())
    # @unpack
    # def test_2(self, txt, xuzhu):
    #     print(txt)
    #     print(xuzhu)
    #     print('********')

    # @file_data('ppp.yml')
    # def test_2(self, txt):
    #     print(txt)
    #     print('********')

    # @file_data('ppp.yml')
    # def test_2(self, **kwargs):
    #     # 获取参数中 key 为 name 的 vlaue
    #     name = kwargs.get('name')
    #     print(name)
    #     self.assertNotEqual(first=name,second='xuzhu',msg='NotEqual')
    #     # 获取参数中 key 为 test 的 vlaue
    #     print(kwargs.get('test'))
    #     print('********')


    def test_5(self):
        print('5')

    # 无条件跳过执行该条用例
    # @unittest.skip('理由就是不想运行')
    def test_1(self):
        print('1')

    # 有条件执行跳过操作
    # @unittest.skipUnless(1>2,'这是Unless的理由')
    def test_3(self):
        print('3')

    # 有条件执行跳过操作
    # @unittest.skipIf(1<2,'这是if的理由')
    def test_2(self):
        print('2')

    # 如果用例执行失败，则不计入失败的case中
    @unittest.expectedFailure
    def test_4(self):
        print('4')
        self.assertEqual(4,3,msg='notEqual')


if __name__ == '__main__':
    # readFile()
    unittest.main()